//
//  HLWaybillCell.m
//  zhuanxian
//
//  Created by zhaoliang chen on 2017/11/17.
//  Copyright © 2017年 huiling. All rights reserved.
//

#import "HLWaybillCell.h"

@interface HLWaybillCell()

@property(nonatomic,strong)UILabel* labelWaybillNumber;
@property(nonatomic,strong)UILabel* labelWaybillDate;
@property(nonatomic,strong)UILabel* labelSendStation;
@property(nonatomic,strong)UILabel* labelRecvStation;
@property(nonatomic,strong)UILabel* labelState;
@property(nonatomic,strong)UILabel* labelPipe;
@property(nonatomic,strong)UILabel* labelPayment;       //到付运费
@property(nonatomic,strong)UILabel* labelCollection;    //委托代收

@end

@implementation HLWaybillCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        UIView* view1 = [UIView new];
        [self.contentView addSubview:view1];
        [view1 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.top.right.mas_equalTo(self.contentView);
            make.height.mas_equalTo(50);
        }];
        
        [view1 addSubview:self.labelWaybillNumber];
        [self.labelWaybillNumber mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(5);
            make.centerY.mas_equalTo(view1);
        }];
        
        [view1 addSubview:self.labelWaybillDate];
        [self.labelWaybillDate mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(-5);
            make.centerY.mas_equalTo(self.labelWaybillNumber);
        }];
        
        UIView* line1 = [UIView new];
        line1.backgroundColor = BackColor;
        [self.contentView addSubview:line1];
        [line1 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.height.mas_equalTo(1);
            make.left.right.mas_equalTo(self.contentView);
            make.top.mas_equalTo(view1.mas_bottom);
        }];
        
        UIView* view2 = [UIView new];
        [self.contentView addSubview:view2];
        [view2 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(-5);
            make.width.mas_equalTo(80);
            make.top.mas_equalTo(line1.mas_bottom);
            make.height.mas_equalTo(120);
        }];

        UIView* view3 = [UIView new];
        [self.contentView addSubview:view3];
        [view3 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(5);
            make.right.mas_equalTo(view2.mas_left);
            make.top.height.mas_equalTo(view2);
        }];

        UILabel* label1 = [UILabel new];
        label1.text = @"状态:";
        label1.textColor = TextColor;
        [view2 addSubview:label1];
        [label1 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(view2);
            make.centerY.mas_equalTo(view2.mas_top).offset(40);
        }];

        [view2 addSubview:self.labelState];
        [self.labelState mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(view2);
            make.centerY.mas_equalTo(label1);
        }];

        UIImageView* imgV = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"hl_arrow_right"]];
        imgV.contentMode = UIViewContentModeCenter;
        [view3 addSubview:imgV];
        [imgV mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.mas_equalTo(view3);
            make.centerY.mas_equalTo(view3.mas_top).offset(40);
            make.size.mas_equalTo(25);
        }];

        [view3 addSubview:self.labelSendStation];
        [self.labelSendStation mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.mas_equalTo(imgV);
            make.left.mas_equalTo(5);
        }];

        [view3 addSubview:self.labelRecvStation];
        [self.labelRecvStation mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.mas_equalTo(imgV);
            make.left.mas_equalTo(imgV.mas_right).offset(5);
        }];
        
        [view3 addSubview:self.labelPipe];
        [self.labelPipe mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(5);
            make.bottom.mas_equalTo(-10);
        }];
        
        UIView* line2 = [UILabel new];
        line2.backgroundColor = line1.backgroundColor;
        [self.contentView addSubview:line2];
        [line2 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(view3.mas_bottom);
            make.left.right.mas_equalTo(self.contentView);
            make.height.mas_equalTo(1);
        }];
        
        UIView* view4 = [UIView new];
        [self.contentView addSubview:view4];
        [view4 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.mas_equalTo(self.contentView);
            make.height.mas_equalTo(50);
            make.top.mas_equalTo(line2.mas_bottom);
        }];
        
        UILabel* label2 = [UILabel new];
        label2.text = @"到付运费:";
        [view4 addSubview:label2];
        [label2 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.mas_equalTo(view4);
            make.left.mas_equalTo(5);
        }];
        
        [view4 addSubview:self.labelPayment];
        [self.labelPayment mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.mas_equalTo(view4);
            make.left.mas_equalTo(label2.mas_right);
        }];
        
        [view4 addSubview:self.labelCollection];
        [self.labelCollection mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.mas_equalTo(view4);
            make.right.mas_equalTo(-5);
        }];
        
        UILabel* label4 = [UILabel new];
        label4.text = @"委托代收:";
        [view4 addSubview:label4];
        [label4 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.mas_equalTo(view4);
            make.right.mas_equalTo(self.labelCollection.mas_left);
        }];
        
        UIView* line3 = [UIView new];
        line3.backgroundColor = BackColor;
        [self.contentView addSubview:line3];
        [line3 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.height.mas_equalTo(10);
            make.left.right.mas_equalTo(self.contentView);
            make.top.mas_equalTo(view4.mas_bottom);
            make.bottom.mas_equalTo(self.contentView);
        }];
    }
    return self;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)setWaybillObject:(HLWaybillObject *)waybillObject {
    _waybillObject = waybillObject;
    self.labelSendStation.text = waybillObject.startOffWebsite;
    self.labelRecvStation.text = waybillObject.destinationWebsite;
    self.labelWaybillNumber.text = waybillObject.waybillNumber;
    self.labelWaybillDate.text = waybillObject.waybillCreateDate;
    self.labelState.text = waybillObject.statusMsg;
    self.labelPipe.text = [NSString stringWithFormat:@"%@/%@kg/%@立方 %@件",waybillObject.cargoName,waybillObject.cargoWeight,waybillObject.cargoVolume,waybillObject.cargoCount];
    self.labelPayment.text = [NSString stringWithFormat:@"￥%@",waybillObject.totalFees];
}

- (UILabel*)labelWaybillNumber {
    if (!_labelWaybillNumber) {
        _labelWaybillNumber = [UILabel new];
        _labelWaybillNumber.textColor = MainColor;
        _labelWaybillNumber.text = @"运单号:";
    }
    return _labelWaybillNumber;
}

- (UILabel*)labelWaybillDate {
    if (!_labelWaybillDate) {
        _labelWaybillDate = [UILabel new];
        _labelWaybillDate.textColor = TextColor;
        _labelWaybillDate.text = @"开单日期:";
        _labelWaybillDate.textAlignment = NSTextAlignmentRight;
    }
    return _labelWaybillDate;
}

- (UILabel*)labelSendStation {
    if (!_labelSendStation) {
        _labelSendStation = [UILabel new];
        _labelSendStation.textColor = MainColor;
        _labelSendStation.font = [UIFont systemFontOfSize:25];
        _labelSendStation.text = @"出发网点";
    }
    return _labelSendStation;
}

- (UILabel*)labelRecvStation {
    if (!_labelRecvStation) {
        _labelRecvStation = [UILabel new];
        _labelRecvStation.textColor = [UIColor orangeColor];
        _labelRecvStation.text = @"到达网点";
        _labelRecvStation.font = [UIFont systemFontOfSize:25];
        _labelRecvStation.textAlignment = NSTextAlignmentRight;
    }
    return _labelRecvStation;
}

- (UILabel*)labelState {
    if (!_labelState) {
        _labelState = [UILabel new];
        _labelState.textColor = MainColor;
        _labelState.textAlignment = NSTextAlignmentRight;
        _labelState.text = @"新建";
    }
    return _labelState;
}

- (UILabel*)labelPipe {
    if (!_labelPipe) {
        _labelPipe = [UILabel new];
        _labelPipe.text = @"配件/0.0kg/0.0立方    1件";
    }
    return _labelPipe;
}

- (UILabel*)labelPayment {
    if (!_labelPayment) {
        _labelPayment = [UILabel new];
        _labelPayment.textColor = MainColor;
        _labelPayment.text = @"￥0.0";
    }
    return _labelPayment;
}

- (UILabel*)labelCollection {
    if (!_labelCollection) {
        _labelCollection = [UILabel new];
        _labelCollection.textColor = MainColor;
        _labelCollection.textAlignment = NSTextAlignmentRight;
        _labelCollection.text = @"￥0.0";
    }
    return _labelCollection;
}

@end
